<template>
  <div class="direct-booking-info-container">
    <div class="booking-title">Direct Booking</div>
    <div class="booking-summary">
      <div class="booking-count">486</div>
      <div class="review-count">Reviews</div>
    </div>
    <!-- 图表部分 -->
    <div class="chart-details" style="width: 100%">
      <div class="separator"></div>
      <div class="keywords-title">Keywords</div>
      <div class="keyword-list">
        <div class="keyword-item">Discounts /<span>128 reviews</span></div>
        <div class="keyword-item">
          Temperature control accurate /<span>76 reviews</span>
        </div>
        <div class="keyword-item">
          Aesthetic appeal /<span>189 reviews</span>
        </div>
        <div class="keyword-item">
          Promotions & Membership Benefits /<span>93 reviews</span>
        </div>
        <!-- <div class="keyword-item">
          Room spaciousness /<span>65 reviews</span>
        </div> -->
      </div>

      <div class="view-all" @click="handleClickTitle">View All</div>
    </div>
    <div v-if="isPopupVisible" class="popup-container">
      <div class="mask" @click="closePopup"></div>
      <div class="popup-content">
        <KeyWords :keywordData="directKeywordsData" @close="closePopup" />
      </div>
    </div>
  </div>
</template>

<script>
import KeyWords from "./KeyWords.vue";
// export default {
//   components: {
//     PieChart
//   }
// }
export default {
  components: {
    KeyWords,
  },
  data() {
    return {
      isPopupVisible: false, //弹出框
      directKeywordsData: {
        title: "Direct Booking Keywords",
        totalReviews: 1045, // 修正后的值
        keywords: [
          {
            title: "Rooftop view",
            score: 8.9,
            reviewCount: 210,
            sentiment: "12 positive",
          },
          {
            title: "Check-in process",
            score: 4.8,
            reviewCount: 280,
            sentiment: "5 negative",
          },
          {
            title: "Breakfast variety",
            score: 7.1,
            reviewCount: 190,
            sentiment: "8 positive",
          },
          {
            title: "Wi-Fi quality",
            score: 6.3,
            reviewCount: 220,
            sentiment: "2 negative",
          },
          {
            title: "Mattress comfort",
            score: 8.5,
            reviewCount: 145,
            sentiment: "9 positive",
          },
        ],
      },
    };
  },
  methods: {
    handleClickTitle(title, content) {
      // this.popupContent = content;
      this.isPopupVisible = true;
    },
    closePopup() {
      this.isPopupVisible = false;
      // this.popupContent = "";
    },
  },
};
</script>

<style scoped lang="scss">
.popup-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000; // 确保在最上层

  .mask {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1;
  }

  .popup-content {
    position: relative;
    z-index: 2;
    width: 100%; // 可根据需要调整宽度
    max-width: 733px; // 最大宽度限制
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    overflow: hidden;
  }
}
.popup-content {
  margin-bottom: 10px;
}

.mask {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5); // 半透明黑色背景
  z-index: 9;
}
.direct-booking-info-container {
  text-align: center;
  padding: 24px;
  display: flex;
  height: 100%;
  flex-direction: column;
  justify-content: space-between; // 修改为center
  align-items: center;
  .booking-title {
    // flex: 1;
    // margin-bottom: 83px;
    font-size: .125rem;
    font-weight: 600;
    text-align: center;
    color: #454545;
    // margin-top: 155px;
  }
  .booking-summary {
    // flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    .booking-count {
      font-size: .2917rem;
      font-weight: 700;
      color: #232323;
    }
    .review-count {
      font-size: .125rem;
      font-weight: 600;
      color: #8f8f8f;
    }
  }

  .chart-details {
    // width: 100%;
    .separator {
      height: 1px;
      background-color: #b0aaaa;
      margin-bottom: 8px;
    }
    .keywords-title {
      margin-bottom: 8px;
      font-size: .0972rem;
      font-weight: 600;
      color: #232323;
      text-align: center;
    }

    .keyword-list {
      display: flex;
      flex-direction: column;
      // align-items: center;
      font-size: .0833rem;
      text-align: start;

      .keyword-item {
        // margin-right: 19px;
        margin-bottom: 8px;
        font-size: .0694rem;
        font-weight: 400;
        color: #6a6969;
        span {
          color: #232323;
          font-size: .0694rem;
          font-weight: 600;
          margin-left: 4px;
        }
      }
    }
    .view-all {
      text-align: center;
      color: #4199e1;
      font-size: .0694rem;
      font-weight: 600;
    }
    // 使用 ::v-deep 穿透 scoped 作用域
    ::v-deep .view-all:hover {
      opacity: 0.7;
      cursor: pointer;
    }
  }
}
</style>
